﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;

/// <summary>
/// Summary description for Dns
/// </summary>
public static class DNS
{
	public static List<string> GetHostsOnIp( string ipAddress )
	{
		List<string> ids = new List<string>();
		try 
		{
			//IPAddress hostIPAddress = IPAddress.Parse(IpAddressString);
			IPHostEntry hostInfo = System.Net.Dns.GetHostEntry(ipAddress); //.GetHostByAddress(hostIPAddress);
			// Get the IP address list that resolves to the host names contained in 
			// the Alias property.
			IPAddress[] address = hostInfo.AddressList;
			// Get the alias names of the addresses in the IP address list.
			String[] alias = hostInfo.Aliases;
			ids.Add(hostInfo.HostName);
			for(int index=0; index < alias.Length; index++)
				ids.Add(alias[index]);
			for(int index=0; index < address.Length; index++)
				ids.Add(address[index].ToString());
		}
		catch(Exception e)
		{
			//Console.WriteLine("Exception caught!!!");
			//Console.WriteLine("Source : " + e.Source);
			//Console.WriteLine("Message : " + e.Message);
		}
		return ids;
	}
}